package com.kaoshi.management.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kaoshi.management.pojo.XtManagement;
import com.kaoshi.management.mapper.XtManagementMapper;
import com.kaoshi.management.service.XtManagementService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-10-29
 */
@Service
public class XtManagementServiceImpl extends ServiceImpl<XtManagementMapper, XtManagement> implements XtManagementService {

    @Override
    public Page<XtManagement> getPageList(Integer current, Integer pageSize, XtManagement xtManagement) {

        Page<XtManagement> page = new Page<>(current, pageSize);

        LambdaQueryWrapper<XtManagement> wrapper = new LambdaQueryWrapper<>();

        // 假设我们要对xtManagement的名称进行模糊查询
        if (xtManagement.getName() != null && !xtManagement.getName().isEmpty()) {
            wrapper.like(XtManagement::getName, xtManagement.getName());
        }

        return baseMapper.selectPage(page, wrapper);
    }

    @Override
    public List<XtManagement> getBq() {
        QueryWrapper<XtManagement> xtManagementQueryWrapper = new QueryWrapper<>();
        xtManagementQueryWrapper.eq("status",0);
        xtManagementQueryWrapper.select("name");
        List<XtManagement> xtManagements = baseMapper.selectList(xtManagementQueryWrapper);
        return xtManagements;
    }
}
